/***URLConf By GYLite 2022-12-26
 * Url管理类，提供各种资源的Url地址以及url版本、配置变更等功能
*/
class URLConf {
	public static DEFAULT_ROOT:string = "";
	public static MODULE_KEY:string = "moduleRelease";
	public static MODULELIB_KEY:string = "moduleLibRelease";	
	public static modules:string;
	public static moduleLibs:string;
	public static videoRoot:string = "";
	public static moduleLibsJS:string = "*/js/*.js";		
	
	public static sketelonAlias:string = "skeleton/";
	public static saveAlias:string = "tipsImg.png";
	public static sound:string = "sound/"
	private static _libVer:string;
	private static _moduleVer:string;
	private static _cfgVer:string;
	private static _resVer:string;    	

	public static resetRoot():void
	{		
		let userData:UserData;
		userData = UserData.getInstance();		
		URLConf.modules = userData.ossRoot + URLConf.MODULE_KEY + "/";
		URLConf.moduleLibs = userData.ossRoot + URLConf.MODULELIB_KEY + "/";
		URLConf.videoRoot = userData.ossRoot + "/";
	}
	/**获取公共库版本
	 * @param w 前置加连接符
	*/
	public static getLibVer(w:string = "?"):string
	{let s = this;
		if(s._libVer == null)
			s._libVer = (window["libVersion"]?window["libVersion"]:"")+GameManager.getInstance().configMgr.libMD5();
		return w + s._libVer;
	}
	/**获取模块版本号
	 * @param w 前置加连接符
	*/
	public static getModuleVer(w: string = "?"): string {
		let s = this;
		if (s._moduleVer == null) {
			let v: string = UserData.getInstance().getQueryVariable("mdVer");			
			if (v == null)
				v = Date.now() + "";			
			s._moduleVer = v;
		}
		return w + (s._moduleVer==""?"":s._moduleVer);
	}
	/**获取主程序配置版本
	 * @param w 前置加连接符
	*/
	public static getCfgVer(w:string = "?"):string
	{let s = this;
		if(s._cfgVer == null)
			s._cfgVer = UserData.getInstance().getQueryVariable("c_v");
		return w + (s._cfgVer?GameManager.version + "_" + s._cfgVer:GameManager.version);
	}
	/**获取主程序资源版本
	 * @param w 前置加连接符
	*/
	public static getResVer(w:string = "?"):string
	{let s = this;
		if(s._resVer == null)
			s._resVer = UserData.getInstance().getQueryVariable("r_v");
		return w + (s._resVer?GameManager.version + "_" + s._resVer:GameManager.version);		
	}
	/**获取模块路径
	 * 通过url参数 mdDirVer指向
	*/
	// public static getModulePath(module:String, mdDirVer:string=""):string
	// {
	// 	if(mdDirVer == null)
	// 		mdDirVer = "";
	// 	if(mdDirVer == "")
	// 	{
	// 		mdDirVer = UserData.getInstance().getQueryVariable("mdDirVer");		
	// 		if(mdDirVer == null)
	// 			mdDirVer = "";
	// 		mdDirVer = mdDirVer == ""?mdDirVer:mdDirVer + "/";
	// 	}
	// 	let arr:Array<any> = module.split(".");
	// 	if(arr.length > 1)
	// 	{
	// 		let mainModule:string;
	// 		mainModule = arr.shift();
	// 		return URLConf.modules + mainModule + "/" + mdDirVer + arr.join(".");
	// 	}	
			
	// 	return URLConf.modules + mdDirVer + module;
	// }
}